<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>老人信息</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="/senior_assets/css/bootstrap.min.css" rel="stylesheet">
	<link href="/senior_assets/css/style.css" rel="stylesheet">
	<link href="/senior_assets/css/font-awesome.css" rel="stylesheet">
</head>
<body>
	<div class="container-fluid">
		<div class="om-ctl-mes">
			<div class="title">
				<div class="col-xs-12"><span class="fa fa-list-ul"> 老人管理</span><b class="fa fa-caret-right"></b><i>老人信息</i></div>
			</div>
			<div class="seltemple">
				<div class="col-xs-12">
					<form class="form-inline" method="get" action="/admin_senior">
					<?if($_COOKIE['admin']['roles'] == 1 || $_COOKIE['admin']['roles'] == 2){?>
					<div class="col-xs-3 mes-group"><label>部门</label><select name="department"><option>请选择</option><?foreach($tDIDatas as $tDIRow){?><option value="<?=$tDIRow['num']?>" <?if($pDepartment == $tDIRow['num']){echo 'selected';}?>><?=$tDIRow['introduce']?></option>
					<?}?></select><?}?></div>
                    <div class="col-xs-3 sel-data">
                    <label for="exampleInputName2">入院时间</label>
                    <div class="input-group date form_date" data-date="" data-date-format="yyyy-mm-dd" data-link-field="updated">
                    <input class="form-control" size="16" id="jcnow"  readonly="" placeholder="选择入院日期" type="text" name="created"  value="<?=$pCreated?>" onclick="WdatePicker();" style="width:1.2rem">
                    </div>
                    <input id="updated" value="" name="updated" type="hidden"><br>
                    		
                    </div>			
					<div class="col-xs-3 mes-search"><label>关键词搜索</label><input type="text" placeholder="老人姓名/委托人电话" name="name" value="<?=$pName?>"><button id='search'>搜索</button></div>
					</form>
					<div class="col-xs-3 mes-btn"><!-- <button id="off-btn" type="button">批量导入</button> --><button type="button" onclick="senioradd(window.location='/admin_senior/add')">新增老人</button></div>
				</div>
			</div>

			<div  class="mes-conttent col-xs-12">
				<table class="table">
	              <thead>
	             	<tr>
			        <th>编号</th>
			        <th>老人姓名</th>
			        <th>护工姓名</th>
			        <th>部门</th>
			        <th>性别</th>
			        <th>年龄</th>
			        <th>身体状况</th>
			        <th>入院时间</th>
			        <th>委托人</th>
			        <th>联系电话</th>
			        <th>是否欠费</th>
			        <th>操作</th>
		            </tr>
	              </thead>
	             <tbody>
					<?foreach($tDatas as $tRow){?>
                    <tr>
                        <td><?=$tRow['id']?></td>
                        <td><?=empty($tRow['name'])?'未知姓名':$tRow['name']?></td>
                        <td><?=$tRow['w_name']?></td>
                        <td><?=$tRow['department']?></td>
                        <td><?=$tRow['sex']?></td>
                        <td><?=$tRow['age']?></td>
                        <td><?=$tRow['body_status']?></td>
                        <td><?=date('Y-m-d H:i:s',$tRow['created'])?></td>
                        <td><?=$tRow['wt_name']?></td>
                        <td><?=$tRow['wt_phone']?></td>
                        <td>否</td>
                        <td>
                            <a href="/admin_senior/plan?id=<?=$tRow['id']?>" ><button style="color:black;" type="button">设置</button></a>
                            <a href="/admin_senior/edit?id=<?=$tRow['id']?>" ><button style="color:black;" type="button">详情</button></a>
                            <a href="/admin_senior/editsupportworker?id=<?=$tRow['id']?>" ><button style="color:black;" type="button">绑定护工</button></a>
                        </td>
                    </tr>
                    <?}?>
	            </tbody>
              </table>
                <?=$tShow?>
			</div>
		</div>
    </div>
    <script type="text/javascript" src="/senior_assets/js/jquery.min.js"></script>
    <script type="text/javascript" src="/senior_assets/js/jq.js"></script>
    <script type="text/javascript" src="/plugins/datepicker/WdatePicker.js" charset="UTF-8"></script>
    <script type="text/javascript" src="/plugins/base.js"></script>
	<!-- <script src="/js/jquery.form.js"></script>form表单插件 -->
	<script type="text/javascript" src="/plugins/jquery.validate.min.js"></script>
    <script>
		function senioradd(){}
		/*获取地址栏参数*/
		function GetQuery(key){
			var search = location.search.slice(1);//得到get方式提交的查询字符串
			var arr = search.split("&");
			for(var i = 0; i < arr.length; i++){
				var ar = arr[i].split("=");
				if(ar[0] == key){
					return ar[1];
				}
			}
		}
		$(function(){
			var offalert="<div class='off-alert'></div>",
			    html = "<div class='mark'></div>"
			           +"<div class='off-alert'>"
						  +"<h3>批量导入<b>以Excel表的形式批量导入老人信息</b><span id='close'>×</span></h3><form method='post' id='excelform' >"
						  +"<div class='mid-content'><div class='img-content'><p><span></span><img src='/senior_assets/img/Excel.png'></p><label>老人基本信息表单.excel*</label></div><div class='file-content'><p><input type='file' name='file_stu' id='file_stu'></p></div></div>"
						  +"<div class='btns'><button>选择文件</button><button  id='fileBtn' type='submit'>上传</button></div></form>"
		          +"</div>";
			   $("body").prepend($(html))
			    $(".mark").css("height",$(document).height()+"px")		
			   $(".mark").addClass('hidden')	
			   $(".off-alert").addClass('hidden')
			      $("#off-btn").click(function(){
			           $('.mark').show()
			           $('.off-alert').show()
			           $(".off-alert").removeClass('hidden')
			           $(".mark").removeClass('hidden')
			       
			     })
			    $("#close").click(function(){
			           $('.mark').hide()
			           $('.off-alert').hide()
			           $(".off-alert").addClass('hidden')
			           $(".mark").addClass('hidden')
			     })
			})
		    var data = document.getElementById('file_stu').value;
		    $("#excelform").resetForm().validate({
		        rules:{
		            "file_stu": {
		                required: true,
		                accept: "xlsx"
		            }
		        },
		        messages: {
		            "file_stu": {
		                required: "<font color='red'>请选择上传文件</font>",
		                accept: "<font color='red'>文件格式不支持,请上传xls格式的文件</font>"
		            }
		        },
		        submitHandler:function(){
		            $("#excelform").ajaxSubmit({
		                url:"http://"+domain+"/apiv1_importsenior",
		                type:"post",
		                enctype:"multipart/form-data",
		                contentType:"application/x-www-urlencoded;charset=utf-8",
		                //dataType:"json",
		                success:function(obj){
		                    alert(obj.msg);location.reload();   
		                },
		                error:function(){
		                    alert('error');
		                }
		            }); 
		        }
		    });
		    var input = document.getElementById('file_stu');
		    input.addEventListener('change',readFile,false);
		    function readFile(){
		        var file = this.files[0];
		        return file;
		    }
    </script>
    
</body>
</html>
